<%@ page language="java" import="java.util.*,java.io.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'newfile.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    <%
    	File f1=new File("C:\\Intel\\Logs","1.txt");
    	File f2=new File("2.txt");
    	File f3=new File("c:\\intel\\logs\\dir");
    	File f4=new File("c:\\intel\\logs");
    %>
    F1可读吗？
    <%=f1.canRead() %>
    <br>
    F1路劲
    <%=f1.getAbsolutePath() %>
    <br>
    f1的目录
    <%=f1.getParent()%>
    <br/>
    f3能创建吗？
    <% f3.mkdir(); %>
    <%=f3.mkdir() %>
    <br>
    F3是目录吗？
    <%=f3.isDirectory() %>
    <%
    String filename[]=f3.list();
    for(String st:filename)
    {
    out.print("<br>");
    out.print(st.toString());
    }
    %>
    <br/>
   <%!
   class Filter implements FilenameFilter
   {String st=null;
   Filter(String s)
   {
		st="."+s;   
		
   }
   public boolean accept(File dir,String name)
	{
		return name.endsWith(st);
	}  
   }
   		public void listAllFile(File f)
   {	
   		Filter filters=new Filter("bmp");
   		File file[]=f.listFiles(filters);
	  for(File fa:file)
	  {		
	  		
		  if(fa.isDirectory())
		  {
			  listAllFile(fa);
		  }
		  if(fa.isFile())
		  {
			 System.out.println(fa.toString());
	
			
		  
		  }
	  }
   }
    
   %>
   <h1>------------------</h1>
   
   <%
   listAllFile(f4);
  	  %>
   <% File f5=new File(f4,"cd.bmp");
   	f5.delete();
   %>
  </body>
</html>
